package com.vids.controller;

import com.vids.model.entity.ApeStatus;
import com.vids.service.IApeStatusService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/VIID/APEs")
@RequiredArgsConstructor
public class ApeStatusController {

    private final IApeStatusService apeStatusService;

    /**
     * 查询采集设备状态
     *
     * @return
     */
    @GetMapping(value = "/Status", produces = "application/VIID+JSON;charset=UTF-8")
    public Object getApeStatusList() {
	List<ApeStatus> list = new ArrayList<ApeStatus>();
	try {
	    list = apeStatusService.getApeStatusList();
	} catch (Exception e) {
	    log.error("getApeStatusList Exception" + e.getMessage());
	}
	if (list == null || list.size() == 0) {
	    return new ResponseEntity<Map<String, Object>>(new HashMap<>(), HttpStatus.NO_CONTENT);
	}
	return list;
    }

}
